
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////// Table A9 - Replace Missing ideology with 0 ///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

use Data_OPO_Master.dta, clear

drop dist_pet_coa  dist_resp_coa dist_pet_resp dist_pet_coa_quart dist_resp_coa_quart dist_pet_resp_quart
drop petitioner_odd_party_out respondent_odd_party_out panel_odd_party_out no_odd_party_out

replace sc_pet_atty_cf=0 if sc_pet_atty_cf==.
replace sc_resp_atty_cf=0 if sc_resp_atty_cf==.

**** Calculate Distances Between Parties 

gen dist_pet_coa = abs(sc_pet_atty_cf - coa_panel_med_cf)
xtile dist_pet_coa_quart=dist_pet_coa,n(4)

gen dist_resp_coa = abs(sc_resp_atty_cf - coa_panel_med_cf)
xtile dist_resp_coa_quart=dist_resp_coa,n(4)

gen dist_pet_resp = abs(sc_pet_atty_cf - sc_resp_atty_cf)
xtile dist_pet_resp_quart=dist_pet_resp,n(4)

**** Generate Odd Party Out Buckets

gen petitioner_odd_party_out = 0
replace petitioner_odd_party_out=1 if dist_pet_coa_quart ==4 & dist_resp_coa_quart==1

gen respondent_odd_party_out = 0
replace respondent_odd_party_out=1 if dist_pet_coa_quart ==1 & dist_resp_coa_quart==4

gen panel_odd_party_out = 0
replace panel_odd_party_out=1 if dist_pet_coa_quart ==4 & dist_pet_resp_quart==1

gen no_odd_party_out=0
replace no_odd_party_out=1 if respondent_odd_party_out==0 & petitioner_odd_party_out==0 & panel_odd_party_out==0 


** A. All Cases

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  i.sc_term i.coa_circuit  , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_A.tex", nocons replace tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  coa_enbanc coa_panel_dissent coa_lc_reversed dismissed  i.sc_term i.coa_circuit  , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  using "TableA9_A.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln i.sc_term i.coa_circuit  , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_A.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit  , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_A.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

** B. Civil Cases

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  i.sc_term i.coa_circuit if civil==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_B.tex", nocons replace tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  coa_enbanc coa_panel_dissent coa_lc_reversed dismissed  i.sc_term i.coa_circuit  if civil==1, cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  using "TableA9_B.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln i.sc_term i.coa_circuit if civil==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_B.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit if civil==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_B.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)


** C. Criminal Cases

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  i.sc_term i.coa_circuit if criminal==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_C.tex", nocons replace tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  coa_enbanc coa_panel_dissent coa_lc_reversed dismissed  i.sc_term i.coa_circuit if criminal==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  using "TableA9_C.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln i.sc_term i.coa_circuit if criminal==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_C.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

reg sc_cert_granted panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out  coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit if criminal==1 , cluster(sc_term)
outreg2 panel_odd_party_out respondent_odd_party_out petitioner_odd_party_out   using "TableA9_C.tex", nocons append tex dec(3) drop(coa_enbanc coa_panel_dissent coa_lc_reversed dismissed sc_cert_sg_petitioner sc_cert_sg_respondent sc_pet_corp sc_resp_corp sc_pet_pro_se sc_pet_vet_atty_ln  i.sc_term i.coa_circuit)

